<template>
   <div>
     <h1>详情</h1>
    {{books}}
    <div>
        
    </div>
   </div>
</template>

<script setup>
import {ref,onMounted} from "vue";
// 导入当前路由钩子
import {useRoute} from "vue-router"
// 调用钩子 获得当前路由信息
    const route=useRoute()
    const books=ref("")
    const query=()=>{
        fetch(`http://localhost:3000/books/${route.query.pid}`)
        .then(res=>res.json())
        .then(data=>{
            books.value=data
        })
    }
    onMounted(()=>{
        query()
    })
</script>

<style scoped>

</style>